﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Tool.Framework;
@using VirtualPress.Infrastructure.Entities.Enum;
@{
    ViewBag.Title = "ArticleDetail";
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
@section head
{
    <style type="text/css">
        .attachment
        {
        }
        .filelink
        {
            margin-left: 10px;
            width: 45%;
            display: block;
            float: left;
        }
        .type
        {
            width: 100px;
            color: Gray;
            text-align: center;
            display: block;
            float: left;
        }
        .italic
        {
            color: Gray;
            font-style: italic;
        }
        hr
        {
            padding: 0;
            margin: 5px 0 5px 0;
            line-height: 1px;
        }
    </style>
}
<link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        稿件详情</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/Member/Index" class="tip-bottom"><i class="icon-home"></i>起始页</a>
    <a class="current">稿件详情</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span8">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-pencil"></i></span>
                    <h5>
                        期刊投稿</h5>
                    <h5 style="float: right; color: Red;">
                        *为必填</h5>
                </div>
                @{
                    Periodical journal = ViewBag.Journal;
                    Article article = ViewBag.Article;
                    List<ArticleAuthor> author = ViewBag.ArticleAuthor;
                    List<Appendix> Attachment = ViewBag.Attachment;
                }
                <div class="widget-content nopadding">
                    <form id="reviseform" class="form-horizontal" method="post" enctype="multipart/form-data"
                    action="/WorkSpace/member/ArticleRevise">
                    <input type="hidden" name="ArticleId" value="@article.Id" />
                    <div class="step">
                        <div class="control-group">
                            <label class="control-label">
                                期刊名称</label>
                            <div class="controls">
                                <label>@journal.Name</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件标题</label>
                            <div class="controls">
                                <label>@article.Title</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                英文标题</label>
                            <div class="controls">
                                <label>@article.Title_EN</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件范围</label>
                            <div class="controls">
                                <label>@article.GJFW.Replace(";", "、 ")</label>
                            </div>
                        </div>
                        <div id="authorbox" class="control-group">
                            <label class="control-label">
                                稿件作者</label>
                            <div class="controls">
                                @foreach (var item in author)
                                { 
                                    @Html.Raw(item.AuthorName + " ")
                                }
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要</label>
                            <div class="controls">
                                <p>@article.Abstract</p>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字</label>
                            <div class="controls">
                                <label>@article.KeyWords</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要(ENGLISH)</label>
                            <div class="controls">
                                <p>@article.Abstract_EN</p>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字(ENGLISH)</label>
                            <div class="controls">
                                <label>@article.KeyWords_EN</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件</label>
                            <div class="controls">
                                <div>
                                    @if (Attachment != null && Attachment.Any())
                                    {
                                        var chugao = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.ChuGao).ToList();
                                        var xiuding = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.XiuDingGao).ToList();
                                        var zhonggao = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.ZhongGao).ToList();
                                        var dinggao = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.DingGao).ToList();

                                        if (chugao.Any())
                                        {
                                            foreach (var att in chugao)
                                            {
                                        <div class="attachment">
                                            <a class="filelink" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())" title="点击下载">
                                                <i class="icon-download"></i>@att.FileName.PieceOfString(0, 15, "...")</a><span class="type">初稿</span>
                                            <span class="italic">@att.CreateTime.ToString("yyyy-MM-dd")
                                            </span>
                                            @if (!String.IsNullOrEmpty(att.Suggestion))
                                            {

                                                <a style="width:10px; margin-left:10px;" title="查看审稿详情" target="_blank" href="/workspace/member/showsuggestion/@att.Id">
                                                    <i class="icon-envelope icon-larger"></i></a>
                                            }
                                        </div>
                                            }
                                        <hr />
                                        }
                                        if (xiuding.Any())
                                        {
                                            foreach (var att in xiuding)
                                            { 
                                        <div class="attachment">
                                            <a class="filelink" target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())">
                                                <i class="icon-download"></i>@att.FileName</a><span class="type">修订稿</span><span
                                                    class="italic">@att.CreateTime.ToString("yyyy-MM-dd")</span>
                                            @if (!String.IsNullOrEmpty(att.Suggestion))
                                            {

                                                <a style="width:10px; margin-left:10px;" title="查看审稿详情" target="_blank" href="/workspace/member/showsuggestion/@att.Id">
                                                    <i class="icon-envelope icon-larger"></i></a>
                                            }
                                        </div>
                                            }
                                        <hr />
                                        }
                                        if (dinggao.Any())
                                        {
                                            foreach (var att in zhonggao)
                                            {
                                        <div class="attachment">
                                            <a class="filelink" target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())">
                                                <i class="icon-download"></i>@att.FileName</a><span class="type">终稿</span><span class="italic">@att.CreateTime.ToString("yyyy-MM-dd")</span></div>
                                            }
                                        }
                                    }
                                </div>
                            </div>
                        </div>
                        @if (ViewBag.Recommendation != null)
                        {
                            <div class="control-group">
                                <label class="control-label">
                                    专家推荐材料</label>
                                <div class="controls">
                                    <div class="controls-label">
                                        <div class="attachment">
                                            <a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = ViewBag.Recommendation.Id, type = 9 }.ToJson())">
                                                <i class="icon-download"></i>@ViewBag.Recommendation.FileName </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        }
                        @if (article.Status == ArticleStatus.ZhongShenXiuDing || article.Status == ArticleStatus.ZhuanShenXiuDing)
                        { 
                            <div class="control-group">
                                <label class="control-label">
                                    上传修订稿 (*)</label>
                                <div class="controls">
                                    <input type="file" name="Appendix" class="{required:true,accept:'doc|docx|pdf|zip|7z|rar'}" />
                                </div>
                            </div>
                        }
                    </div>
                    <div class="form-actions">
                        <a class="btn btn-primary" href="/workspace/member/article?type=-1">返回</a>
                        @if (article.Status == ArticleStatus.ZhongShenXiuDing || article.Status == ArticleStatus.ZhuanShenXiuDing)
                        {
                            <input id="btnsubmit" class="btn btn-primary" type="submit" value="Submit" />
                        }
                    </div>
                    <div id="submitted">
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="span4">
            <div class="accordion widget-box" id="collapse-group">
                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGOne" data-toggle="collapse"><span
                                class="icon"><i class="icon-magnet"></i></span>
                                <h5>
                                    稿件历史记录</h5>
                            </a>
                        </div>
                    </div>
                    <div class="accordion-body collapse" id="collapseGOne">
                        <div class="widget-content">
                            <ul class="activity-list">
                                @{
                                    List<ArticleHistory> his = ViewBag.History;
                                    if (his != null && his.Any())
                                    {
                                        foreach (var item in his)
                                        {
                                    <li><a href="javascript:;"><i class="icon-chevron-right"></i><strong>@item.Message</strong>
                                        <span>@item.CreateTime.ToString("yyyy-MM-dd")</span> </a></li>
                                        }
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGTwo" data-toggle="collapse"><span
                                class="icon"><i class="icon-magnet"></i></span>
                                <h5>
                                    审稿记录</h5>
                            </a>
                        </div>
                    </div>
                    <div class="accordion-body in collapse" id="collapseGTwo">
                        <div class="widget-content">
                            <ul class="activity-list">
                                @{
                                    List<AuditingRecord> record = ViewBag.AuditingRecord;
                                    if (record != null && record.Any())
                                    {
                                        foreach (var item in record)
                                        {
                                    <li><a href="javascript:;"><i class="icon-chevron-right"></i><strong>@item.Step.Mapping()</strong>
                                        @item.ExamineStatus.Mapping()
                                        <span>@item.CreateTime.ToString("yyyy-MM-dd")</span>
                                        @if (!String.IsNullOrEmpty(@item.Message))
                                        {
                                            <i style="float:right;" title="@item.Message" class="icon-comment"></i>
                                        }
                                    </a></li>
                                        }
                                    }
                                    else
                                    {
                                    <li><a href="javascript:;"><i class="icon-chevron-right"></i>暂无记录 </a></li>
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section tail
{
    <script type="text/javascript">
        $(function () {
            $('#likarticle').addClass('active open');
            $('#reviseform').submit(function () {
                var appendix = $('input:file[name="Appendix"]');
                if (appendix.length > 0) {
                    if (appendix.val() == '') {
                        alert('请上传修订稿');
                        return false;
                    }
                    if (!/\.doc$|\.docx$|\.pdf$|\.zip$|\.7z$|\.rar$/i.test(appendix.val())) {
                        alert('只接收doc|docx|pdf|zip|7z|rar格式的稿件');
                        return false;
                    }
                    $('#btnsubmit').attr('disabled', 'disabled').val('附件上传中');
                }
            });
        });
    </script>
}
